package com.xoa.controller.PartyMember;

import com.xoa.model.partyMember.PartyMemberWithBLOBs;
import com.xoa.service.partyMember.PartyMemberService;
import com.xoa.service.partyMember.impl.PartyMemberServiceImpl;
import com.xoa.util.LimsJson;
import com.xoa.util.ToJson;
import com.xoa.util.dataSource.ContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@Controller
@RequestMapping("partyMember")
public class PartyMemberController {

    //入党申请
    @RequestMapping("/applicationForm")
    public String applicationForm() {
        return "app/PartyMember/applicationForm";
    }
    //入党申请审核
    //@RequestMapping("/applicationReview")
    public String applicationReview() {
        return "app/PartyMember/applicationReview";
    }
    //入党考察审核
    @RequestMapping("/Inspection")
    public String Inspection() {
        return "app/PartyMember/Inspection";
    }
    //发展对象审核
        //@RequestMapping("/potentialObj")
    public String potentialObj() {
        return "app/PartyMember/potentialObj";
    }
    //党员培训审核
    @RequestMapping("/TrainingAudit")
    public String TrainingAudit() {
        return "app/PartyMember/TrainingAudit";
    }
    //党员转正审核
    @RequestMapping("/fullMember")
    public String fullMember() {
        return "app/PartyMember/fullMember";
    }
    //入党申请审核
    @RequestMapping("/auditor")
    public String auditor() {
        return "app/PartyMember/auditor";
    }
    //    发展对象审核表progress
    @RequestMapping("/progress")
    public String progress() {
        return "app/PartyMember/progress";
    }
    //预备党员审核
    @RequestMapping("/prepare")
    public String prepare(){
        return "app/PartyMember/prepare";
    }

    //入党考察
    @RequestMapping("/partyCheck")
    public String partyCheck() {
        return "app/PartyMember/partyCheck";
    }
    //党员培训
    @RequestMapping("/memberTraining")
    public String memberTraining() {
        return "app/PartyMember/memberTraining";
    }
    //党员个人信息
    @RequestMapping("/memberInfo")
    public String memberInfo() {
        return "app/PartyMember/memberInfo";
    }
    //所有入党积极分子
    @RequestMapping("/allActivist")
    public String allActivist() {
        return "app/PartyMember/allActivist";
    }
    //入党积极分子查看
    @RequestMapping("/activistLook")
    public String activistLook() {
        return "app/PartyMember/activistLook";
    }
    //所有发展对象
    @RequestMapping("/developObj")
    public String developObj() {
        return "app/PartyMember/developObj";
    }
    //所有预备党员
    @RequestMapping("/prePartyMember")
    public String prePartyMember() {
        return "app/PartyMember/prePartyMember";
    }
    //所有党员信息
    @RequestMapping("/allMemberInfo")
    public String allMemberInfo() {
        return "app/PartyMember/allMemberInfo";
    }

    //党建基础设置
    @RequestMapping("/partyBaseSet")
    public String partyBaseSet() {
        return "app/PartyMember/partyBaseSet";
    }

    //查看入党申请人信息
    @RequestMapping("/allApplicants")
    public String allApplicants() {
        return "app/PartyMember/allApplicants";
    }

    //新思想汇报
    @RequestMapping("/partyTR")
    public String partyTR(){
        return "app/PartyMember/partyTR";
    }
    @Autowired
    private PartyMemberService partyMemberService;


    /**
     * 创建作者: 刘建
     * 创建日期: 2020-07-24 10:54
     * 方法介绍: 根据发展阶段查询
     * @param request
     * @param phase
     * @return com.xoa.util.ToJson<com.xoa.model.partyMember.PartyMemberWithBLOBs>
     */
    @ResponseBody
    @RequestMapping("/selectByPhase")
    public ToJson<PartyMemberWithBLOBs> selectByPhase(HttpServletRequest request , Integer phase,Integer page,Integer limit){
        return partyMemberService.selectByPhase(phase,page,limit);
    }

    /**
     *
     * @作者 李卫卫
     * @创建日期 17:21 2020/8/6
     * @类介绍 预备党员 查询发展阶段为 4 和 5阶段数据
     * @参数
     * @return limsJson
     */

    @ResponseBody
    @RequestMapping("/selectAllPhase")
    public ToJson<PartyMemberWithBLOBs> selectAllPhase(Integer page,Integer limit){
        return partyMemberService.selectAllPhase( page,limit);
    }

    /**
     * 创建作者: 刘建
     * 创建日期: 2020-07-24 10:54
     * 方法介绍: 查询自己的申请进度
     * @param request
     * @param phase
     * @return com.xoa.util.ToJson<com.xoa.model.partyMember.PartyMemberWithBLOBs>
     */
    @ResponseBody
    @RequestMapping("/findPartyMember")
    public ToJson findPartyMember(HttpServletRequest request , Integer phase){
        return partyMemberService.findPartyMember(request,phase);
    }


    /**
     * 创建作者: 刘建
     * 创建日期: 2020-07-24 13:15
     * 方法介绍: 入党申请
     * @param request
     * @return com.xoa.util.ToJson<com.xoa.model.partyMember.PartyMemberWithBLOBs>
     */
    @ResponseBody
    @RequestMapping("/insertParty")
    public ToJson<PartyMemberWithBLOBs> insertParty(HttpServletRequest request ){
        return partyMemberService.insetParty(request);
    }


    /**
     * 创建作者: 王辰
     * 创建日期: 2020-07-29
     * 方法介绍: 入党流程判断+数据回显
     */
    @ResponseBody
    @RequestMapping("/initParty")
    public ToJson initParty(HttpServletRequest request , Integer phase){
        return partyMemberService.initParty(request,phase);
    }
    /**
     * 创建作者: 王辰
     * 创建日期: 2020-07-29
     * 方法介绍: case0 申请入党应用提交流程接口
     */
    @ResponseBody
    @RequestMapping("/applyParty")
    public ToJson applyParty(HttpServletRequest request, HttpServletResponse response, PartyMemberWithBLOBs partyMemberWithBLOBs, Integer phase, String attrUrls){
        return partyMemberService.applyParty(request,response,partyMemberWithBLOBs,phase,attrUrls);
    }
    /**
     * 创建作者: 王辰
     * 创建日期: 2020-08-04
     * 方法介绍: case2 积极分子应用提交流程
     */
    @ResponseBody
    @RequestMapping("/activeParty")
    public ToJson activeParty(HttpServletRequest request, String userId, Integer phase){
        return partyMemberService.activeParty(request,userId,phase);
    }
    /**
     * 创建作者: 王辰
     * 创建日期: 2020-07-29
     * 方法介绍: case3 确认发展对象应用提交流程
     */
    @ResponseBody
    @RequestMapping("/developParty")
    public ToJson developParty(HttpServletRequest request, String userId, Integer phase){
        return partyMemberService.developParty(request,userId,phase);
    }
    /**
     * 创建作者: 王辰
     * 创建日期: 2020-07-29
     * 方法介绍: 支部书记提交合格党员接口
     */
    @ResponseBody
    @RequestMapping("/passParty")
    public ToJson passParty(HttpServletRequest request,Integer phase,Integer page,Integer limit){
        return partyMemberService.passParty(request,phase,page,limit);
    }
    /**
     * 创建作者: 王辰
     * 创建日期: 2020-07-29
     * 方法介绍: 根据userId 查询个人信息
     */
    @RequestMapping("/partyInfo")
    @ResponseBody
    public ToJson partyInfo(HttpServletRequest request,String userId){
        return partyMemberService.partyInfo(request,userId);
    }
    /**
     * 创建作者: 王辰
     * 创建日期: 2020-07-29
     * 方法介绍: 思想汇报应用跳转流程
     */
    @RequestMapping("/fourReport")
    @ResponseBody
    public ToJson fourReport(HttpServletRequest request){
        return partyMemberService.fourReport(request);
    }
    /**
     * 创建作者: 王辰
     * 创建日期: 2020-07-29
     * 方法介绍: 预备党员跳转流程
     */
    @RequestMapping("/progressParty")
    @ResponseBody
    public ToJson progressParty(HttpServletRequest request,String userId,Integer phase){
        return partyMemberService.progressParty(request,userId,phase);
    }
    /**
     * 创建作者: 王辰
     * 创建日期: 2020-08-19
     * 方法介绍: 党建基础设置回显
     */
    @RequestMapping("/getSysPara")
    @ResponseBody
    public ToJson getSysPara(){
        ToJson toJson = new ToJson(1,"err");
        Map sysPara = partyMemberService.getSysPara();
        if(sysPara.size()>0){
            toJson.setObject(sysPara);
            toJson.setFlag(0);
            toJson.setMsg("成功");
        }
        return toJson;
    }
    /**
     * 创建作者: 王辰
     * 创建日期: 2020-08-19
     * 方法介绍: 党建基础设置保存
     */
    @RequestMapping("/saveSysPara")
    @ResponseBody
    public ToJson saveSysPara(String partySys){
        return partyMemberService.saveSysPara(partySys);
    }
    /**
     * 创建作者: 王辰
     * 创建日期: 2020-10-16
     * 方法介绍: 申请入党跳转非0阶段
     */
    @RequestMapping("/selectPhase")
    @ResponseBody
    public ToJson selectPhase(HttpServletRequest request,PartyMemberWithBLOBs partyMemberWithBLOBs){
        return partyMemberService.selectPhase(request,partyMemberWithBLOBs);
    }
/**
     *
     * @作者 李卫卫
     * @创建日期 12:37 2020/10/17
     * @类介绍 党建导出功能
     * @参数
     * @return limsJson
     */

    @RequestMapping("/getFileExport")
    @ResponseBody
    public LimsJson getFileExport(HttpServletRequest request, HttpServletResponse response, Integer phase){
        return partyMemberService.getFileExport(request,response,phase);
    }

    //导出党员阶段为 4和5 阶段数据
    @RequestMapping("/gainFileExport")
    @ResponseBody
    public LimsJson getFileExport(HttpServletRequest request, HttpServletResponse response) {
        return partyMemberService.getFileExport(request,response);
    }

    /**
     * 创建作者: 王辰
     * 创建日期: 2020-10-20
     * 方法介绍: 每个发展阶段回显的下载模板
     */
    @RequestMapping("/getTemp")
    @ResponseBody
    public ToJson getTemp(HttpServletRequest request,Integer phase){
        String sqlType = "xoa" + (String) request.getSession().getAttribute(
                "loginDateSouse");
        ContextHolder.setConsumerType(sqlType);
        return partyMemberService.getTemp(request,phase,sqlType);
    }
    /**
     * 创建作者: 王辰
     * 创建日期: 2020-10-20
     * 方法介绍: 更变入党介绍人,更变培养联系人
     */
    @RequestMapping("/selectDCandRP")
    @ResponseBody
    public ToJson selectDCandRP(HttpServletRequest request,String type,String userId){
        return partyMemberService.selectDCandRP(request,type,userId);
    }


    //根据用户选择所属党支部类型查询
    @RequestMapping("/getPartyMemberList")
    @ResponseBody
    public ToJson getPartyMemberList(String parentPedtId,String phase1, String phase2, Integer page, Integer limit) {
        return partyMemberService.getPartyMemberList(parentPedtId,phase1,phase2,limit,page);
    }

    /**
     *  王辰
     *  2020-10-26
     *  思想汇报附件上传删除接口
     *  url:附件地址
     *  type:新增0删除1
     *  n:需要删除的附件下标
     */
    @RequestMapping("/updateTR")
    @ResponseBody
    public ToJson updateTR(HttpServletRequest request,String url,Integer type,Integer n){
        return partyMemberService.updateTR(request,url,type,n);
    }
    /**
     * 王辰
     * 2020-10-28
     * 暴力初始化党建第一步,删除所有党建流程用的数据
     * 此接口很危险
     */
    @RequestMapping("/initOne")
    @ResponseBody
    public ToJson initOne(Integer flowSort){
        return partyMemberService.initOne(flowSort);
    }
    /**
     * 王辰
     * 2020-10-28
     * 暴力初始化党建第二步,删除所有党建用的表单
     * 此接口很危险
     *//*
    @RequestMapping("/initTwo")
    @ResponseBody
    public ToJson initTwo(Integer flowSort){
        return partyMemberService.initOne(flowSort);
    }*/


    /**
     * 王辰
     * 2020-10-28
     * 更新党建流程
     * 此接口很危险
     */
    @RequestMapping("/updatePartyMemberFlowable")
    @ResponseBody
    public ToJson updatePartyMemberFlowable(HttpServletRequest request){
        return partyMemberService.updatePartyMemberFlowable(request);
    }
}
